package com.xuyiwei.mayi.test;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;

/**
 * Created by xuyiwei on 2019/4/13.
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(1);
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程开始执行");
                latch.countDown();
                System.out.println("线程减1");
            }
        });
        t1.start();
        latch.await();
        System.out.println("主线程已经执行结束");
    }
}
